<?php
defined('SEJUJOPEFDNGJSL') or exit('Access denied');

$pagecount=getnums($_GET["pagecount"],$GLOBALARR['pagecount']);
$option=getnums($_GET['option'],1);
$orderby=getnums($_GET['orderby'],1);
$quser=checkstr(trim($_GET['quser']));

$bgtime=checkstr(trim($_GET['bgtime']));
$edtime=checkstr(trim($_GET['edtime']));

$tmp_arr['toption'].='<a href="'.getqueurl('option',1).'" class="'.geteqval(array($option,1,'taselbtn','thabtn')).'">今日新增</a>'
        . '<a href="'.getqueurl('option',2).'" class="'.geteqval(array($option,2,'taselbtn','thabtn')).'">全部</a>'
        . '<a href="'.getqueurl('option',3).'" class="'.geteqval(array($option,3,'taselbtn','thabtn')).'">LTC</a>'
        . '<a href="'.getqueurl('option',4).'" class="'.geteqval(array($option,4,'taselbtn','thabtn')).'">BTC</a>'
        // . '<a href="'.getqueurl('option',5).'" class="'.geteqval(array($option,5,'taselbtn','thabtn')).'">审核未通过</a>'
        // . '<a href="'.getqueurl('option',6).'" class="'.geteqval(array($option,6,'taselbtn','thabtn')).'">本金</a>'
        // . '<a href="'.getqueurl('option',7).'" class="'.geteqval(array($option,7,'taselbtn','thabtn')).'">利息</a>'
        // . '<a href="'.getqueurl('option',8).'" class="'.geteqval(array($option,8,'taselbtn','thabtn')).'">动态奖</a>'
        // . '<a href="'.getqueurl('option',9).'" class="'.geteqval(array($option,9,'taselbtn','thabtn')).'">晋级奖</a>'
        ;


$tmp_arr['torderby']='<a href="'.getqueurl('orderby',geteqval(array($orderby,1,'2','1'))).'" class="'.((strstr($orderby,'1')||strstr($orderby,'2'))?"tpaixusel":"tpaixu").'">'.geteqval(array($orderby,1,'时间↓','时间↑')).'</a>
   <a href="../downout.php?&type=0&time1='.$_GET['bgtime'].'&time2='.$_GET['edtime'].'&quser='.$_GET['quser'].'"><font color="red"></font></a>
';

if(is_array($GLOBALARR['jjname'])){
	foreach ($GLOBALARR['jjname'] as $k => $v) {
		$tmp_arr['tcolor'].='<a href="javascript:;" class="theacolor levelcolor'.$k.'">'.$v.'</a>';
	}
}

$condition=' where 1=1 and type=0';
if($quser){
		$condition.=" and cuname like '%".$quser."%' ";
}
if($bgtime &&$edtime){
	$bgtimes=strtotime($bgtime." 00:00:00");
	$edtimes=strtotime($edtime." 23:59:59");
	$condition.=" and ctime <".$edtimes." and ctime>".$bgtimes."";

}
//status :0等待对配1等待打款2配对已过期3已取消 status_value:0收益中1收益结束2中断收益结束
if($option==1) $condition.=" and from_unixtime(ctime,'%Y-%m-%d')='".date('Y-m-d')."'";
if($option==3) $condition.=" and `coin`='ltc' ";// 
if($option==4) $condition.=" and coin='btc'";//
if($option==5) $condition.=' and `is_cross`=2';//
if($option==6) $condition.=' and `ctype`=0 and is_cross=1';
if($option==7) $condition.=' and `ctype`=1 and is_cross=1';
if($option==8) $condition.=' and `ctype`=2 and is_cross=1';
if($option==9) $condition.=' and `ctype`=3 and is_cross=1';
$order='';


if($orderby==1) $order=' order by ctime desc';
if($orderby==2) $order=' order by ctime asc';


$tmp_arr['tth']='<th>序号</th><th>会员名称</th><th>币种</th><th>兑换时间</th><th>转出数量</th><th>到账pbc数量</th><th>币种单价</th><th>pbc单价</th><th>总金额</th>';


$psql="select count(0) from ld_zhuanhuan_log $condition";
$db->query($psql,3);
$pcount=$db->fval;
$pagecount=$pagecount;   //每页条数 
$astr="&lsaction=zhuanlist&pagecount=$pagecount&orderby=$orderby&option=$option&quser=$quser&bgtime=$bgtime&edtime=$edtime";	  //Url
$pagearr=pagelist($pagecount,$pcount,$astr);
$offset=$pagearr[1];

$sql="select * from ld_zhuanhuan_log  $condition $order limit $offset,$pagecount";
$db->query($sql);
$ii=0;
foreach ($db->rs as $k => $v) {
	$ii++;
	$serialid=($pagearr[2]-1)*$pagecount+$ii;
	if($v['ctype']==0){
		$type="本金";
	}elseif($v['ctype']==1){
		$type="利息";
	}elseif($v['ctype']==2){
		$type="动态奖";
	}elseif($v['ctype']==3){
		$type="晋级奖";
	}
	if($v['is_cross']==0){
		$ztai="未审核";
	}elseif($v['is_cross']==1){
		$ztai="审核通过";

	}elseif($v['is_cross']==2){
		$ztai="审核失败";
	}
	$tmp_arr['ttr'].='<tr class="levelcolor">
						<td><span  title="'.$v["id"].'">'.$serialid.'</span></td>
                        <td>'.$v['cuname'].'</td>
                        <td>'.$v['coin'].'</td>    
						<td>'.date("Y-m-d H:i:s",$v['ctime']).'</td>
						<td>'.$v['num'].'</td>
						<td>'.$v['sjnum'].'</td>
                        <td>'.$v['cprice']*$v['rate'].'</td>
                        <td>'.$v['pbc_price'].'</td>
                        
                        <td>'.$v['ctotal'].'</td>
						';
	$tmp_arr['ttr'].='</tr>';
}


$tmp_arr['tcount']=$pcount;
$tmp_arr['ttitle']=getmenu($GLOBALARR['menu'],'lockip');
$tmp_arr['tpage']=$pagearr[0];

function admin_huan($arr){
echo '	<h3>'.$arr['ttitle'].'</h3>
	<div class="main-r-body"><form method="get" action="?">
	<div class="main-r-item"><input type="submit" class="thabtn" value="查询"><input type="input" class="tsearch" name="quser">
	<input type="input" class="tsearch" name="bgtime">---
	<input type="input" class="tsearch" name="edtime"><span class="paixutxt">排序<span>：'.$arr['torderby'];
if(!empty($arr["twhereoption"])){
echo '<span class="colortxt">账户类型：<span>'.$arr["twhereoption"];
}
if(!empty($arr["tcolorone"])){
echo '<span class="colortxt">导出：<span>'.$arr['tcolorone'];
}
echo '</div>';
		$questr=explode("&",$_SERVER["QUERY_STRING"]);
		for($i=0;$i<count($questr);$i++){
			$questrl=explode("=",$questr[$i]);
			if(count($questrl)>0)
			{
				if($questrl[1]!=""){
					if(!($questrl[0]=="quser")){
						echo '<input type="hidden" name="'.$questrl[0].'" value="'.$questrl[1].'">';
					}
				}
			}
		}
echo '	</form><form method="post" action="'.geturl().'">
	<div class="main-r-item" '.$arr["styles"].'>'.$arr['toption'].'</div>	';

echo '<table class="thealist ttab">
		<tr>
'.$arr['tth'].'
		</tr>
		<tbody>';
if($arr['tcount']>0){
echo $arr['ttr'];
}
echo '	</tbody>					
	</table></form>';
if($arr['tcount']==0){
echo '<div class="nodata">暂无数据</div>';
}else{
echo '	<div class="pages">
		<div class="floatr">
'.$arr['tpage'].'
		</div>
	</div>	';
}

echo '</div>';
}
admin_huan($tmp_arr);
$timecha='';
if($bgtime &&$edtime){
	$timecha.=" and ctime <".$edtimes." and ctime>".$bgtimes."";

}
if($quser){
		$timecha.=" and cuname like '%".$quser."%' ";
}
if($option==1){
	$sql="select sum(ctotal) as total from ld_transfer_coin where type=0 and from_unixtime(ctime,'%Y-%m-%d')='".date('Y-m-d')."' ";
	$db->query($sql,2);
	$sum=$db->rs['total'];
	echo "<div style='font-size:14px;'><span>兑换总金额合计：".$sum;
}
if($option==2 ||$option==''){
	$sql="select sum(ctotal) as total from ld_transfer_coin where type=0  $timecha ";
	$db->query($sql,2);
	$sum=$db->rs['total'];
	echo "<div style='font-size:14px;'><span>兑换总金额合计：".$sum;
}
if($option==3){
	$sql="select sum(ctotal) as total from ld_transfer_coin where type=0 and `is_cross`=0  $timecha ";
	$db->query($sql,2);
	$sum=$db->rs['total'];
	echo "<div style='font-size:14px;'><span>总金额合计：".$sum;

}
if($option==4){
	$sql="select sum(ctotal) as total from ld_transfer_coin where type=0 and `is_cross`=1  $timecha ";
	$db->query($sql,2);
	$sum=$db->rs['total'];
	echo "<div style='font-size:14px;'><span>总金额合计：".$sum;

}
if($option==5){
	$sql="select sum(ctotal) as total from ld_transfer_coin where type=0 and `is_cross`=2  $timecha ";
	$db->query($sql,2);
	$sum=$db->rs['total'];
	echo "<div style='font-size:14px;'><span>总金额合计：".$sum;

}
if($option==6){
	$sql="select sum(ctotal) as total from ld_transfer_coin where type=0 and ctype=0 and `is_cross`=1  $timecha ";
	$db->query($sql,2);
	$sum=$db->rs['total'];
	echo "<div style='font-size:14px;'><span>总金额合计：".$sum;

}
if($option==7){
	$sql="select sum(ctotal) as total from ld_transfer_coin where type=0 and ctype=1 and `is_cross`=1  $timecha ";
	$db->query($sql,2);
	$sum=$db->rs['total'];
	echo "<div style='font-size:14px;'><span>总金额合计：".$sum;

}
if($option==8){
	$sql="select sum(ctotal) as total from ld_transfer_coin where type=0 and ctype=2 and `is_cross`=1  $timecha ";
	$db->query($sql,2);
	$sum=$db->rs['total'];
	echo "<div style='font-size:14px;'><span>总金额合计：".$sum;

}
if($option==9){
	$sql="select sum(ctotal) as total from ld_transfer_coin where type=0 and ctype=3 and `is_cross`=1   $timecha ";
	$db->query($sql,2);
	$sum=$db->rs['total'];
	echo "<div style='font-size:14px;'><span>总金额合计：".$sum;

}
?>